package com;

import com.fastDFS.FastDFSTemplate;
import com.netty.fileupload.server.WebSocketServer;
import io.netty.channel.ChannelFuture;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.net.InetSocketAddress;

/**
 * com
 *
 * @Auther: caiming
 * @Date: 2018/11/5 09:15
 * @Description:
 */
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(Application.class, args);
        FastDFSTemplate fastDFSTemplate = (FastDFSTemplate)context.getBean("fastDFSTemplate");
        System.out.println(fastDFSTemplate);
        final WebSocketServer endpoint = new WebSocketServer(fastDFSTemplate);
        ChannelFuture future = endpoint.start(new InetSocketAddress(9999));
        Runtime.getRuntime().addShutdownHook(new Thread() {
            public void run() {
                endpoint.destroy();
            }
        });

        future.channel().closeFuture().syncUninterruptibly();
    }
}
